﻿using System;
using System.Web.Mvc;

namespace JinianNet.Web.MVC
{
    public class TemplateViewEngine: ViewEngine
    {

        public TemplateViewEngine(string[] viewLocation, string[] masterLocation, string[] areaMasterLocation, string[] areaViewLocation, string[] partialViewLocation, string[] areaPartialViewLocation):
            base(viewLocation,masterLocation,areaMasterLocation,areaViewLocation,partialViewLocation,areaPartialViewLocation)
        {
        }

        public TemplateViewEngine(string[] viewLocation)
            : this(viewLocation,viewLocation,viewLocation,viewLocation,viewLocation,viewLocation)
        {

        }

        public TemplateViewEngine():
            this(new string[]{
                "~/Template/{0}.html",
                "~/Template/{3}/{0}.html",
                "~/Template/{1}/{0}.html",
                "~/Template/{3}/{1}/{0}.html",

                "~/Template/{2}/{0}.html",
                "~/Template/{2}/{1}/{0}.html",
                "~/Template/{3}/{2}/{0}.html",
                "~/Template/{3}/{2}/{1}/{0}.html"
            })
        {
        }

        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
        {
            return new TemplateView(partialPath);
        }

        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
        {
            return new TemplateView(viewPath);//new TemplateView(viewPath, masterPath);
        }
    }
}
